package com.jt.ktdemo.ui

import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleObserver
import androidx.lifecycle.OnLifecycleEvent
import com.jt.ktdemo.utils.LogUtil

class MyObservabler : LifecycleObserver {

    /**
    可以被感知的生命周期
    ON_CREATE
    ON_START
    ON_RESUMR
    ON_PAUSE
    ON_STOP
    ON_DESTORY
    ON_ANY：表示可以匹配组件任何的生命周期的回调
     */
    @OnLifecycleEvent(Lifecycle.Event.ON_CREATE)
    fun compatCreate(){
        LogUtil.e("onCreate")
    }
    @OnLifecycleEvent(Lifecycle.Event.ON_START)
    fun compatStart() {
        LogUtil.d("onStart")
    }

    @OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
    fun compatResume(){
        LogUtil.d("onResume")
    }

    @OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
    fun compatPause(){
        LogUtil.d("onPause")
    }

    @OnLifecycleEvent(Lifecycle.Event.ON_STOP)
    fun comatStop(){
        LogUtil.d("onStop")
    }

    @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
    fun compatDestory(){
        LogUtil.d("onDestory")
    }

}